#define _CRT_SECURE_NO_WARNINGS   1
#include<stdio.h>
#include<stdlib.h>

int** restore(int**M, int* n,int* m)
{
	int p = 0;
	int q = 0;
	scanf("%d %d", &p, &q);
	
	int** M1 = (int**)malloc(p * sizeof(int*));
	for (int i = 0; i < p; i++)
		M1[i] = (int*)malloc(q * sizeof(int));
	int* A = (int*)malloc((*n)*(*m)*sizeof(int));
	int x = 0;
	for (int i = 0; i < *n; i++)
	{
		for (int j = 0; j < *m; j++)
		{
			A[x] = M[i][j];
			x++;
		}

	}
	x = 0;
	for (int i = 0; i < p; i++)
	{
		for (int j = 0; j < q; j++)
		{
			M1[i][j] = A[x];
			x++;
		}

	}
	*n = p;
	*m = q;
	free(A);
	free(M);
	  return M1;
}
int** resposing(int** M, int* n,int* m)
{

	int** M1 = (int**)malloc((*m) * sizeof(int*));
	for (int i = 0; i < *m; i++)
		M1[i] = (int*)malloc((*n) * sizeof(int));
	for (int i = 0; i < *m; i++)
	{
		for (int j = 0; j < *n; j++)
		{
			M1[i][j] = M[j][i];

		}

	}
	int tmp = 0;
	tmp= *n ;
	 *n=*m;
	 *m = tmp;
	free(M);
	return M1;

}
int main()
{
	int n = 0;
	int m = 0;
	int t = 0;
	scanf("%d %d %d",&n,&m,&t);
	
	int** M = (int**)malloc(n*sizeof(int*));
	for (int i = 0; i < n; i++)
		M[i] = (int*)malloc(m*sizeof(int));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			scanf("%d",&M[i][j]);
		}

	}
	/*M= restore(M,&n,&m);

	M =resposing(M, &n, &m);*/
	int i = 0;
	int j = 0;
	int* x = (int*)malloc(t*sizeof(int));
	int h = 0;
	while (t--)
	{
		int input = 0;
		scanf("%d",&input);
		switch (input) {
		case 1:
			M = restore(M, &n, &m);
			break;
		case 2:
		
			scanf("%d %d", &i, &j);
			if(i==0&&j==0)
				M = resposing(M, &n, &m); 
			break;
		
		case 3:
			scanf("%d %d",&i,&j);
			  x[h]= M[i][j];
			  h++;
			break;
		default:
			printf("buxi\n ");
			t++;
			break;
		}
		


	}
	for (int i = 0; i < h; i++)
	{
		printf("%d",x[i]);
		printf("\n");

	}
 


	return 0;
}